/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
package com.hercules.xre.protocol.testing.handlers;

import com.hercules.xre.protocol.testing.EventHandler;
import com.topcoder.util.log.Log;
import com.topcoder.util.log.LogManager;

/**
 * This class is the base class of the event handlers defined in this component. This class provides the logging
 * variable, getter and setter to be used by subclass.
 * <p>
 * <b>Thread safety:</b> This class is thread safe since a simple get/set on non-primitive variable is thread safe.
 *
 * @author bramandia, 7realm
 * @version 1.0
 */
public abstract class BaseEventHandler implements EventHandler {
    /**
     * Represents the logger to be used. Initialized to null. Has getter/setter. Can be null to indicate no logging.
     */
    private Log logger;

    /**
     * Default empty constructor.
     */
    protected BaseEventHandler() {
        // empty
    }

    /**
     * Gets the logger to be used.
     *
     * @return the logger to be used
     */
    public Log getLogger() {
        return logger;
    }

    /**
     * Sets the logger to be used.
     *
     * @param logger the new value of the logger to be used
     */
    public void setLogger(Log logger) {
        this.logger = logger;
    }

    /**
     * Sets the logger by name.
     *
     * @param loggerName the name of the logger, can be any value
     */
    public void setLoggerName(String loggerName) {
        logger = LogManager.getLog(loggerName);
    }
}
